package com.university.evaluation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.university.evaluation.entity.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 系统用户Mapper
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    /**
     * 根据角色查询用户列表
     */
    @Select("SELECT * FROM t_sys_user WHERE role = #{role}")
    List<SysUser> findByRole(@Param("role") String role);

    /**
     * 根据学院ID查询用户列表
     */
    @Select("SELECT * FROM t_sys_user WHERE college_id = #{collegeId}")
    List<SysUser> findByCollegeId(@Param("collegeId") String collegeId);

    /**
     * 根据角色和学院ID查询用户列表
     */
    @Select("SELECT * FROM t_sys_user WHERE role = #{role} AND college_id = #{collegeId}")
    List<SysUser> findByRoleAndCollegeId(@Param("role") String role, @Param("collegeId") String collegeId);

    /**
     * 根据用户名查询用户（登录用）
     */
    @Select("SELECT * FROM t_sys_user WHERE user_id = #{userId}")
    SysUser findByUserId(@Param("userId") String userId);
}
